package com.aash.service;

import org.dozer.Mapper;
import org.springframework.beans.factory.annotation.Autowired;

public abstract class GenericService<DaoModel,ServiceModel> {

	@Autowired
	private Mapper beanMapper;
	
	private Class<DaoModel> daoModelType;
	
	private Class<ServiceModel> serviceModelType;
	
	public GenericService(Class<DaoModel> daoModelType, Class<ServiceModel> serviceModelType) {
		this.daoModelType = daoModelType;
		this.serviceModelType = serviceModelType;
	}
	
	protected DaoModel getDaoModel(ServiceModel serviceModel) {
		return beanMapper.map(serviceModel, daoModelType);
	}
	
	protected ServiceModel getServiceModel(DaoModel daoModel) {
		return beanMapper.map(daoModel, serviceModelType);
	}
}
